home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 6 / MacAddict_006_1997_02.iso / Software Updates / MacsBug 6.5.3 / Building dcmds / C Samples / Where.c < prev   
Encoding:
C/C++ Source or Header  |  1996-02-22  |  2.1 KB  |  86 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Where.c
  3.  
  4.     Contains:    A sample dcmd which displays information about a trap or address.
  5.  
  6.     Written by:    JM3 = Jim Murphy
  7.  
  8.     Copyright:    © 1991, 1994, 1996 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>   25-Jan-96    JM3        Updated the sample build commands to be current.
  13.          <3>   11-Dec-94    JM3        Bleh. I somehow deleted a couple of lines at the end.
  14.          <2>   10-Dec-94    JM3        Updated for new version 3 dcmd requirements.
  15.  
  16.     The following MPW commands will build the dcmd and copy it to the "Debugger Prefs" file
  17.     in the System folder. The dcmd's name in MacsBug will be the name of the file built by
  18.     the Linker.
  19.  
  20.     C Where.c
  21.     Link -o Where -sg Main=STDCLIB,STDIO,SANELIB dcmdGlue.a.o Where.c.o" "{Libraries}Runtime.o"
  22.     BuildDcmd Where 199 -format3
  23.     Echo 'include "Where";'    |    Rez -a -o "{systemFolder}Debugger Prefs"
  24.  
  25.  */
  26.  
  27. #include <Memory.h>
  28. #include <Types.h>
  29. #include "dcmd.h"
  30.  
  31.  
  32. pascal void CommandEntry (dcmdBlock* paramPtr)
  33. {
  34.  
  35.     short    ch;
  36.     long    address;
  37.     Boolean    ok;
  38.     Str255    name;
  39.  
  40.     static const char usageStr[] = "\p[addr | trap]";
  41.  
  42.     switch (paramPtr->request)
  43.     {
  44.         case dcmdInit:
  45.             break;
  46.  
  47.         case dcmdHelp:
  48.             dcmdDrawLine("\pDisplay information about the address or trap.");
  49.             dcmdDrawLine("\pIf no parameter then use PC as the address.");
  50.             break;
  51.  
  52.         case dcmdGetInfo:
  53.             * (long *) &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->dcmdVersion = 0x03008000; // version 3.0 final
  54.             BlockMoveData(&usageStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->usageStr, usageStr[0]+1);
  55.             break;
  56.  
  57.         case dcmdDoIt:
  58.             if (dcmdPeekAtNextChar () == '\n')
  59.                 address = paramPtr->registerFile[PCRegister];
  60.             else
  61.             {
  62.                 ch = dcmdGetNextExpression (&address, &ok);
  63.                 if (!ok)
  64.                 {
  65.                     dcmdDrawLine ("\pSyntax error");
  66.                     return;
  67.                 }
  68.             }
  69.  
  70.             if (address >= 0x0000A000 && address <= 0x0000ABFF)
  71.             {
  72.                 dcmdGetTrapName (address, name);
  73.                 dcmdDrawLine (name);
  74.             }
  75.             else
  76.             {
  77.                 dcmdGetNameAndOffset (address, name);
  78.                 if (name[0] > 0)
  79.                     dcmdDrawLine (name);
  80.                 else
  81.                     dcmdDrawLine ("\pNo procedure name found");
  82.             }
  83.             break;
  84.         }
  85. } // CommandEntry
  86.